home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: Alpha / Whiteline Alpha.iso / progtool / c / gcc / gcc258s.zoo / aux-output.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-30  |  60.3 KB  |  2,353 lines

  1. /* Subroutines for insn-output.c for Motorola 68000 family.
  2.    Copyright (C) 1987, 1993 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20.  
  21. /* Some output-actions in m68k.md need these.  */
  22. #include <stdio.h>
  23. #include "config.h"
  24. #include "rtl.h"
  25. #include "regs.h"
  26. #include "hard-reg-set.h"
  27. #include "real.h"
  28. #include "insn-config.h"
  29. #include "conditions.h"
  30. #include "insn-flags.h"
  31. #include "output.h"
  32. #include "insn-attr.h"
  33.  
  34. /* Needed for use_return_insn.  */
  35. #include "flags.h"
  36.  
  37. #ifdef SUPPORT_SUN_FPA
  38.  
  39. /* Index into this array by (register number >> 3) to find the
  40.    smallest class which contains that register.  */
  41. enum reg_class regno_reg_class[]
  42.   = { DATA_REGS, ADDR_REGS, FP_REGS,
  43.       LO_FPA_REGS, LO_FPA_REGS, FPA_REGS, FPA_REGS };
  44.  
  45. #endif /* defined SUPPORT_SUN_FPA */
  46.  
  47. /* This flag is used to communicate between movhi and ASM_OUTPUT_CASE_END,
  48.    if SGS_SWITCH_TABLE.  */
  49. int switch_table_difference_label_flag;
  50.  
  51. static rtx find_addr_reg ();
  52. rtx legitimize_pic_address ();
  53.  
  54.  
  55. /* Emit a (use pic_offset_table_rtx) if we used PIC relocation in the 
  56.    function at any time during the compilation process.  In the future 
  57.    we should try and eliminate the USE if we can easily determine that 
  58.    all PIC references were deleted from the current function.  That would 
  59.    save an address register */
  60.    
  61. void
  62. finalize_pic ()
  63. {
  64.   if (flag_pic && flag_pic < 3 && current_function_uses_pic_offset_table)
  65.     emit_insn (gen_rtx (USE, VOIDmode, pic_offset_table_rtx));
  66. }
  67.  
  68.  
  69. /* This function generates the assembly code for function entry.
  70.    STREAM is a stdio stream to output the code to.
  71.    SIZE is an int: how many units of temporary storage to allocate.
  72.    Refer to the array `regs_ever_live' to determine which registers
  73.    to save; `regs_ever_live[I]' is nonzero if register number I
  74.    is ever used in the function.  This function is responsible for
  75.    knowing which registers should not be saved even if used.  */
  76.  
  77.  
  78. /* Note that the order of the bit mask for fmovem is the opposite
  79.    of the order for movem!  */
  80.  
  81.  
  82. void
  83. output_function_prologue (stream, size)
  84.      FILE *stream;
  85.      int size;
  86. {
  87.   register int regno;
  88.   register int mask = 0;
  89.   int num_saved_regs = 0;
  90.   extern char call_used_regs[];
  91.   int fsize = (size + 3) & -4;
  92.   
  93.  
  94.   if (frame_pointer_needed)
  95.     {
  96.       /* Adding negative number is faster on the 68040.  */
  97.       if (fsize < 0x8000 && !TARGET_68040)
  98.     {
  99. #ifdef MOTOROLA
  100.       asm_fprintf (stream, "\tlink.w %s,%0I%d\n",
  101.                reg_names[FRAME_POINTER_REGNUM], -fsize);
  102. #else
  103.       asm_fprintf (stream, "\tlink %s,%0I%d\n",
  104.                reg_names[FRAME_POINTER_REGNUM], -fsize);
  105. #endif
  106.     }
  107.       else if (TARGET_68020)
  108.     {
  109. #ifdef MOTOROLA
  110.       asm_fprintf (stream, "\tlink.l %s,%0I%d\n",
  111.                reg_names[FRAME_POINTER_REGNUM], -fsize);
  112. #else
  113.       asm_fprintf (stream, "\tlink %s,%0I%d\n",
  114.                reg_names[FRAME_POINTER_REGNUM], -fsize);
  115. #endif
  116.     }
  117.       else
  118.     {
  119. #ifdef MOTOROLA
  120.       asm_fprintf (stream, "\tlink.w %s,%0I0\n\tadd.l %0I%d,%Rsp\n",
  121.                reg_names[FRAME_POINTER_REGNUM], -fsize);
  122. #else
  123.       asm_fprintf (stream, "\tlink %s,%0I0\n\taddl %0I%d,%Rsp\n",
  124.                reg_names[FRAME_POINTER_REGNUM], -fsize);
  125. #endif
  126.     }
  127.     }
  128.   else if (fsize)
  129.     {
  130.       /* Adding negative number is faster on the 68040.  */
  131.       if (fsize + 4 < 0x8000)
  132.     {
  133. #ifdef MOTOROLA
  134.       asm_fprintf (stream, "\tadd.w %0I%d,%Rsp\n", - (fsize + 4));
  135. #else
  136.       asm_fprintf (stream, "\taddw %0I%d,%Rsp\n", - (fsize + 4));
  137. #endif
  138.     }
  139.       else
  140.     {
  141. #ifdef MOTOROLA
  142.       asm_fprintf (stream, "\tadd.l %0I%d,%Rsp\n", - (fsize + 4));
  143. #else
  144.       asm_fprintf (stream, "\taddl %0I%d,%Rsp\n", - (fsize + 4));
  145. #endif
  146.     }
  147.     }
  148. #ifdef SUPPORT_SUN_FPA
  149.   for (regno = 24; regno < 56; regno++)
  150.     if (regs_ever_live[regno] && ! call_used_regs[regno])
  151.       {
  152. #ifdef MOTOROLA
  153.     asm_fprintf (stream, "\tfpmovd %s,-(%Rsp)\n",
  154.              reg_names[regno]);
  155. #else
  156.     asm_fprintf (stream, "\tfpmoved %s,%Rsp@-\n",
  157.              reg_names[regno]);
  158. #endif
  159.       }
  160. #endif
  161.   for (regno = 16; regno < 24; regno++)
  162.     if (regs_ever_live[regno] && ! call_used_regs[regno])
  163.        mask |= 1 << (regno - 16);
  164.   if ((mask & 0xff) != 0)
  165.     {
  166. #ifdef MOTOROLA
  167.       asm_fprintf (stream, "\tfmovm %0I0x%x,-(%Rsp)\n", mask & 0xff);
  168. #else
  169.       asm_fprintf (stream, "\tfmovem %0I0x%x,%Rsp@-\n", mask & 0xff);
  170. #endif
  171.     }
  172.   mask = 0;
  173.   for (regno = 0; regno < 16; regno++)
  174.     if (regs_ever_live[regno] && ! call_used_regs[regno])
  175.       {
  176.         mask |= 1 << (15 - regno);
  177.         num_saved_regs++;
  178.       }
  179.   if (frame_pointer_needed)
  180.     {
  181.       mask &= ~ (1 << (15 - FRAME_POINTER_REGNUM));
  182.       num_saved_regs--;
  183.     }
  184.  
  185. #if NEED_PROBE
  186.   fprintf (stream, "\ttstl sp@(%d)\n", NEED_PROBE - num_saved_regs * 4);
  187. #endif
  188.  
  189.   if (num_saved_regs <= 2)
  190.     {
  191.       /* Store each separately in the same order moveml uses.
  192.          Using two movel instructions instead of a single moveml
  193.          is about 15% faster for the 68020 and 68030 at no expense
  194.          in code size */
  195.  
  196.       int i;
  197.  
  198.       /* Undo the work from above. */
  199.       for (i = 0; i< 16; i++)
  200.         if (mask & (1 << i))
  201.           asm_fprintf (stream,
  202. #ifdef MOTOROLA
  203.                "\t%Omove.l %s,-(%Rsp)\n",
  204. #else
  205.                "\tmovel %s,%Rsp@-\n",
  206. #endif
  207.                reg_names[15 - i]);
  208.     }
  209.   else if (mask)
  210.     {
  211. #ifdef MOTOROLA
  212.       asm_fprintf (stream, "\tmovm.l %0I0x%x,-(%Rsp)\n", mask);
  213. #else
  214.       asm_fprintf (stream, "\tmoveml %0I0x%x,%Rsp@-\n", mask);
  215. #endif
  216.     }
  217.   if (flag_pic && flag_pic < 3 && current_function_uses_pic_offset_table)
  218.     {
  219. #ifdef MOTOROLA
  220.       asm_fprintf (stream, "\t%Olea (%Rpc, %U_GLOBAL_OFFSET_TABLE_@GOTPC), %s\n",
  221.            reg_names[PIC_OFFSET_TABLE_REGNUM]);
  222. #else
  223.       asm_fprintf (stream, "\tmovel %0I__GLOBAL_OFFSET_TABLE_, %s\n",
  224.            reg_names[PIC_OFFSET_TABLE_REGNUM]);
  225.       asm_fprintf (stream, "\tlea %Rpc@(0,%s:l),%s\n",
  226.            reg_names[PIC_OFFSET_TABLE_REGNUM],
  227.            reg_names[PIC_OFFSET_TABLE_REGNUM]);
  228. #endif
  229.     }
  230. }
  231.  
  232. /* Return true if this function's epilogue can be output as RTL.  */
  233.  
  234. int
  235. use_return_insn ()
  236. {
  237.   int regno;
  238.  
  239.   if (!reload_completed || frame_pointer_needed || get_frame_size () != 0)
  240.     return 0;
  241.   
  242.   /* Copied from output_function_epilogue ().  We should probably create a
  243.      separate layout routine to perform the common work.  */
  244.   
  245.   for (regno = 0 ; regno < FIRST_PSEUDO_REGISTER ; regno++)
  246.     if (regs_ever_live[regno] && ! call_used_regs[regno])
  247.       return 0;
  248.   
  249.   return 1;
  250. }
  251.  
  252. /* This function generates the assembly code for function exit,
  253.    on machines that need it.  Args are same as for FUNCTION_PROLOGUE.
  254.  
  255.    The function epilogue should not depend on the current stack pointer!
  256.    It should use the frame pointer only, if there is a frame pointer.
  257.    This is mandatory because of alloca; we also take advantage of it to
  258.    omit stack adjustments before returning.  */
  259.  
  260. void
  261. output_function_epilogue (stream, size)
  262.      FILE *stream;
  263.      int size;
  264. {
  265.   register int regno;
  266.   register int mask, fmask;
  267.   register int nregs;
  268.   int offset, foffset, fpoffset;
  269.   extern char call_used_regs[];
  270.   int fsize = (size + 3) & -4;
  271.   int big = 0;
  272.   rtx insn = get_last_insn ();
  273.   
  274.   /* If the last insn was a BARRIER, we don't have to write any code.  */
  275.   if (GET_CODE (insn) == NOTE)
  276.     insn = prev_nonnote_insn (insn);
  277.   if (insn && GET_CODE (insn) == BARRIER)
  278.     {
  279.       /* Output just a no-op so that debuggers don't get confused
  280.      about which function the pc is in at this address.  */
  281.       asm_fprintf (stream, "\tnop\n");
  282.       return;
  283.     }
  284.  
  285. #ifdef FUNCTION_EXTRA_EPILOGUE
  286.   FUNCTION_EXTRA_EPILOGUE (stream, size);
  287. #endif
  288.   nregs = 0;  fmask = 0; fpoffset = 0;
  289. #ifdef SUPPORT_SUN_FPA
  290.   for (regno = 24 ; regno < 56 ; regno++)
  291.     if (regs_ever_live[regno] && ! call_used_regs[regno])
  292.       nregs++;
  293.   fpoffset = nregs * 8;
  294. #endif
  295.   nregs = 0;
  296.   for (regno = 16; regno < 24; regno++)
  297.     if (regs_ever_live[regno] && ! call_used_regs[regno])
  298.       {
  299.         nregs++;
  300.     fmask |= 1 << (23 - regno);
  301.       }
  302.   foffset = fpoffset + nregs * 12;
  303.   nregs = 0;  mask = 0;
  304.   if (frame_pointer_needed)
  305.     regs_ever_live[FRAME_POINTER_REGNUM] = 0;
  306.   for (regno = 0; regno < 16; regno++)
  307.     if (regs_ever_live[regno] && ! call_used_regs[regno])
  308.       {
  309.         nregs++;
  310.     mask |= 1 << regno;
  311.       }
  312.   offset = foffset + nregs * 4;
  313.   if (offset + fsize >= 0x8000
  314.       && frame_pointer_needed
  315.       && (mask || fmask || fpoffset))
  316.     {
  317. #ifdef MOTOROLA
  318.       asm_fprintf (stream, "\t%Omove.l %0I%d,%Ra0\n", -fsize);
  319. #else
  320.       asm_fprintf (stream, "\tmovel %0I%d,%Ra0\n", -fsize);
  321. #endif
  322.       fsize = 0, big = 1;
  323.     }
  324.   if (nregs <= 2)
  325.     {
  326.       /* Restore each separately in the same order moveml does.
  327.          Using two movel instructions instead of a single moveml
  328.          is about 15% faster for the 68020 and 68030 at no expense
  329.          in code size. */
  330.  
  331.       int i;
  332.  
  333.       /* Undo the work from above. */
  334.       for (i = 0; i< 16; i++)
  335.         if (mask & (1 << i))
  336.           {
  337.             if (big)
  338.           {
  339. #ifdef MOTOROLA
  340.         asm_fprintf (stream, "\t%Omove.l -%d(%s,%Ra0.l),%s\n",
  341.                  offset + fsize,
  342.                  reg_names[FRAME_POINTER_REGNUM],
  343.                  reg_names[i]);
  344. #else
  345.         asm_fprintf (stream, "\tmovel %s@(-%d,%Ra0:l),%s\n",
  346.                  reg_names[FRAME_POINTER_REGNUM],
  347.                  offset + fsize, reg_names[i]);
  348. #endif
  349.           }
  350.             else if (! frame_pointer_needed)
  351.           {
  352. #ifdef MOTOROLA
  353.         asm_fprintf (stream, "\t%Omove.l (%Rsp)+,%s\n",
  354.                  reg_names[i]);
  355. #else
  356.         asm_fprintf (stream, "\tmovel %Rsp@+,%s\n",
  357.                  reg_names[i]);
  358. #endif
  359.           }
  360.             else
  361.           {
  362. #ifdef MOTOROLA
  363.         asm_fprintf (stream, "\t%Omove.l -%d(%s),%s\n",
  364.                  offset + fsize,
  365.                  reg_names[FRAME_POINTER_REGNUM],
  366.                  reg_names[i]);
  367. #else
  368.         asm_fprintf (stream, "\tmovel %s@(-%d),%s\n",
  369.                  reg_names[FRAME_POINTER_REGNUM],
  370.                  offset + fsize, reg_names[i]);
  371. #endif
  372.           }
  373.             offset = offset - 4;
  374.           }
  375.     }
  376.   else if (mask)
  377.     {
  378.       if (big)
  379.     {
  380. #ifdef MOTOROLA
  381.       asm_fprintf (stream, "\tmovm.l -%d(%s,%Ra0.l),%0I0x%x\n",
  382.                offset + fsize,
  383.                reg_names[FRAME_POINTER_REGNUM],
  384.                mask);
  385. #else
  386.       asm_fprintf (stream, "\tmoveml %s@(-%d,%Ra0:l),%0I0x%x\n",
  387.                reg_names[FRAME_POINTER_REGNUM],
  388.                offset + fsize, mask);
  389. #endif
  390.     }
  391.       else if (! frame_pointer_needed)
  392.     {
  393. #ifdef MOTOROLA
  394.       asm_fprintf (stream, "\tmovm.l (%Rsp)+,%0I0x%x\n", mask);
  395. #else
  396.       asm_fprintf (stream, "\tmoveml %Rsp@+,%0I0x%x\n", mask);
  397. #endif
  398.     }
  399.       else
  400.     {
  401. #ifdef MOTOROLA
  402.       asm_fprintf (stream, "\tmovm.l -%d(%s),%0I0x%x\n",
  403.                offset + fsize,
  404.                reg_names[FRAME_POINTER_REGNUM],
  405.                mask);
  406. #else
  407.       asm_fprintf (stream, "\tmoveml %s@(-%d),%0I0x%x\n",
  408.                reg_names[FRAME_POINTER_REGNUM],
  409.                offset + fsize, mask);
  410. #endif
  411.     }
  412.     }
  413.   if (fmask)
  414.     {
  415.       if (big)
  416.     {
  417. #ifdef MOTOROLA
  418.       asm_fprintf (stream, "\tfmovm -%d(%s,%Ra0.l),%0I0x%x\n",
  419.                foffset + fsize,
  420.                reg_names[FRAME_POINTER_REGNUM],
  421.                fmask);
  422. #else
  423.       asm_fprintf (stream, "\tfmovem %s@(-%d,%Ra0:l),%0I0x%x\n",
  424.                reg_names[FRAME_POINTER_REGNUM],
  425.                foffset + fsize, fmask);
  426. #endif
  427.     }
  428.       else if (! frame_pointer_needed)
  429.     {
  430. #ifdef MOTOROLA
  431.       asm_fprintf (stream, "\tfmovm (%Rsp)+,%0I0x%x\n", fmask);
  432. #else
  433.       asm_fprintf (stream, "\tfmovem %Rsp@+,%0I0x%x\n", fmask);
  434. #endif
  435.     }
  436.       else
  437.     {
  438. #ifdef MOTOROLA
  439.       asm_fprintf (stream, "\tfmovm -%d(%s),%0I0x%x\n",
  440.                foffset + fsize,
  441.                reg_names[FRAME_POINTER_REGNUM],
  442.                fmask);
  443. #else
  444.       asm_fprintf (stream, "\tfmovem %s@(-%d),%0I0x%x\n",
  445.                reg_names[FRAME_POINTER_REGNUM],
  446.                foffset + fsize, fmask);
  447. #endif
  448.     }
  449.     }
  450.   if (fpoffset != 0)
  451.     for (regno = 55; regno >= 24; regno--)
  452.       if (regs_ever_live[regno] && ! call_used_regs[regno])
  453.         {
  454.       if (big)
  455.         {
  456. #ifdef MOTOROLA
  457.           asm_fprintf (stream, "\tfpmovd -%d(%s,%Ra0.l), %s\n",
  458.                fpoffset + fsize,
  459.                reg_names[FRAME_POINTER_REGNUM],
  460.                reg_names[regno]);
  461. #else
  462.           asm_fprintf (stream, "\tfpmoved %s@(-%d,%Ra0:l), %s\n",
  463.                reg_names[FRAME_POINTER_REGNUM],
  464.                fpoffset + fsize, reg_names[regno]);
  465. #endif
  466.         }
  467.       else if (! frame_pointer_needed)
  468.         {
  469. #ifdef MOTOROLA
  470.           asm_fprintf (stream, "\tfpmovd (%Rsp)+,%s\n",
  471.                reg_names[regno]);
  472. #else
  473.           asm_fprintf (stream, "\tfpmoved %Rsp@+, %s\n",
  474.                reg_names[regno]);
  475. #endif
  476.         }
  477.       else
  478.         {
  479. #ifdef MOTOROLA
  480.           asm_fprintf (stream, "\tfpmovd -%d(%s), %s\n",
  481.                fpoffset + fsize,
  482.                reg_names[FRAME_POINTER_REGNUM],
  483.                reg_names[regno]);
  484. #else
  485.           asm_fprintf (stream, "\tfpmoved %s@(-%d), %s\n",
  486.                reg_names[FRAME_POINTER_REGNUM],
  487.                fpoffset + fsize, reg_names[regno]);
  488. #endif
  489.         }
  490.       fpoffset -= 8;
  491.     }
  492.   if (frame_pointer_needed)
  493.     fprintf (stream, "\tunlk %s\n",
  494.          reg_names[FRAME_POINTER_REGNUM]);
  495.   else if (fsize)
  496.     {
  497.       if (fsize + 4 < 0x8000)
  498.     {
  499. #ifdef MOTOROLA
  500.       asm_fprintf (stream, "\tadd.w %0I%d,%Rsp\n", fsize + 4);
  501. #else
  502.       asm_fprintf (stream, "\taddw %0I%d,%Rsp\n", fsize + 4);
  503. #endif
  504.     }
  505.       else
  506.     {
  507. #ifdef MOTOROLA
  508.       asm_fprintf (stream, "\tadd.l %0I%d,%Rsp\n", fsize + 4);
  509. #else
  510.       asm_fprintf (stream, "\taddl %0I%d,%Rsp\n", fsize + 4);
  511. #endif
  512.     }
  513.     }
  514.   if (current_function_pops_args)
  515.     asm_fprintf (stream, "\trtd %0I%d\n", current_function_pops_args);
  516.   else
  517.     fprintf (stream, "\trts\n");
  518. }
  519.  
  520. /* Similar to general_operand, but exclude stack_pointer_rtx.  */
  521.  
  522. int
  523. not_sp_operand (op, mode)
  524.      register rtx op;
  525.      enum machine_mode mode;
  526. {
  527.   return op != stack_pointer_rtx && general_operand (op, mode);
  528. }
  529.  
  530. /* Return TRUE if X is a valid comparison operator for the dbcc 
  531.    instruction.  
  532.  
  533.    Note it rejects floating point comparison operators.
  534.    (In the future we could use Fdbcc).
  535.  
  536.    It also rejects some comparisons when CC_NO_OVERFLOW is set.  */
  537.    
  538. int
  539. valid_dbcc_comparison_p (x, mode)
  540.      rtx x;
  541.      enum machine_mode mode;
  542. {
  543.   /* We could add support for these in the future */
  544.   if (cc_prev_status.flags & CC_IN_68881)
  545.     return 0;
  546.  
  547.   switch (GET_CODE (x))
  548.     {
  549.  
  550.       case EQ: case NE: case GTU: case LTU:
  551.       case GEU: case LEU:
  552.         return 1;
  553.  
  554.       /* Reject some when CC_NO_OVERFLOW is set.  This may be over
  555.          conservative */
  556.       case GT: case LT: case GE: case LE:
  557.         return ! (cc_prev_status.flags & CC_NO_OVERFLOW);
  558.       default:
  559.         return 0;
  560.     }
  561. }
  562.  
  563. /* Output a dbCC; jCC sequence.  Note we do not handle the 
  564.    floating point version of this sequence (Fdbcc).  We also
  565.    do not handle alternative conditions when CC_NO_OVERFLOW is
  566.    set.  It is assumed that valid_dbcc_comparison_p will kick
  567.    those out before we get here.  */
  568.  
  569. output_dbcc_and_branch (operands)
  570.      rtx *operands;
  571. {
  572.  
  573.   switch (GET_CODE (operands[3]))
  574.     {
  575.       case EQ:
  576. #ifdef MOTOROLA
  577.         output_asm_insn ("dbeq %0,%l1\n\tjbeq %l2", operands);
  578. #else
  579.         output_asm_insn ("dbeq %0,%l1\n\tjeq %l2", operands);
  580. #endif
  581.         break;
  582.  
  583.       case NE:
  584. #ifdef MOTOROLA
  585.         output_asm_insn ("dbne %0,%l1\n\tjbne %l2", operands);
  586. #else
  587.         output_asm_insn ("dbne %0,%l1\n\tjne %l2", operands);
  588. #endif
  589.         break;
  590.  
  591.       case GT:
  592. #ifdef MOTOROLA
  593.         output_asm_insn ("dbgt %0,%l1\n\tjbgt %l2", operands);
  594. #else
  595.         output_asm_insn ("dbgt %0,%l1\n\tjgt %l2", operands);
  596. #endif
  597.         break;
  598.  
  599.       case GTU:
  600. #ifdef MOTOROLA
  601.         output_asm_insn ("dbhi %0,%l1\n\tjbhi %l2", operands);
  602. #else
  603.         output_asm_insn ("dbhi %0,%l1\n\tjhi %l2", operands);
  604. #endif
  605.         break;
  606.  
  607.       case LT:
  608. #ifdef MOTOROLA
  609.         output_asm_insn ("dblt %0,%l1\n\tjblt %l2", operands);
  610. #else
  611.         output_asm_insn ("dblt %0,%l1\n\tjlt %l2", operands);
  612. #endif
  613.         break;
  614.  
  615.       case LTU:
  616. #ifdef MOTOROLA
  617.         output_asm_insn ("dbcs %0,%l1\n\tjbcs %l2", operands);
  618. #else
  619.         output_asm_insn ("dbcs %0,%l1\n\tjcs %l2", operands);
  620. #endif
  621.         break;
  622.  
  623.       case GE:
  624. #ifdef MOTOROLA
  625.         output_asm_insn ("dbge %0,%l1\n\tjbge %l2", operands);
  626. #else
  627.         output_asm_insn ("dbge %0,%l1\n\tjge %l2", operands);
  628. #endif
  629.         break;
  630.  
  631.       case GEU:
  632. #ifdef MOTOROLA
  633.         output_asm_insn ("dbcc %0,%l1\n\tjbcc %l2", operands);
  634. #else
  635.         output_asm_insn ("dbcc %0,%l1\n\tjcc %l2", operands);
  636. #endif
  637.         break;
  638.  
  639.       case LE:
  640. #ifdef MOTOROLA
  641.         output_asm_insn ("dble %0,%l1\n\tjble %l2", operands);
  642. #else
  643.         output_asm_insn ("dble %0,%l1\n\tjle %l2", operands);
  644. #endif
  645.         break;
  646.  
  647.       case LEU:
  648. #ifdef MOTOROLA
  649.         output_asm_insn ("dbls %0,%l1\n\tjbls %l2", operands);
  650. #else
  651.         output_asm_insn ("dbls %0,%l1\n\tjls %l2", operands);
  652. #endif
  653.         break;
  654.  
  655.       default:
  656.     abort ();
  657.     }
  658.  
  659.   /* If the decrement is to be done in SImode, then we have
  660.      to compensate for the fact that dbcc decrements in HImode. */
  661.   switch (GET_MODE (operands[0]))
  662.     {
  663.       case SImode:
  664. #ifdef MOTOROLA
  665.         output_asm_insn ("clr%.w %0\n\tsubq%.l %#1,%0\n\tjbpl %l1", operands);
  666. #else
  667.         output_asm_insn ("clr%.w %0\n\tsubq%.l %#1,%0\n\tjpl %l1", operands);
  668. #endif
  669.         break;
  670.  
  671.       case HImode:
  672.         break;
  673.  
  674.       default:
  675.         abort ();
  676.     }
  677. }
  678.  
  679. char *
  680. output_btst (operands, countop, dataop, insn, signpos)
  681.      rtx *operands;
  682.      rtx countop, dataop;
  683.      rtx insn;
  684.      int signpos;
  685. {
  686.   operands[0] = countop;
  687.   operands[1] = dataop;
  688.  
  689.   if (GET_CODE (countop) == CONST_INT)
  690.     {
  691.       register int count = INTVAL (countop);
  692.       /* If COUNT is bigger than size of storage unit in use,
  693.      advance to the containing unit of same size.  */
  694.       if (count > signpos)
  695.     {
  696.       int offset = (count & ~signpos) / 8;
  697.       count = count & signpos;
  698.       operands[1] = dataop = adj_offsettable_operand (dataop, offset);
  699.     }
  700.       if (count == signpos)
  701.     cc_status.flags = CC_NOT_POSITIVE | CC_Z_IN_NOT_N;
  702.       else
  703.     cc_status.flags = CC_NOT_NEGATIVE | CC_Z_IN_NOT_N;
  704.  
  705.       /* These three statements used to use next_insns_test_no...
  706.      but it appears that this should do the same job.  */
  707.       if (count == 31
  708.       && next_insn_tests_no_inequality (insn))
  709.     return "tst%.l %1";
  710.       if (count == 15
  711.       && next_insn_tests_no_inequality (insn))
  712.     return "tst%.w %1";
  713.       if (count == 7
  714.       && next_insn_tests_no_inequality (insn))
  715.     return "tst%.b %1";
  716.  
  717.       cc_status.flags = CC_NOT_NEGATIVE;
  718.     }
  719.   return "btst %0,%1";
  720. }
  721.  
  722. /* Returns 1 if OP is either a symbol reference or a sum of a symbol
  723.    reference and a constant.  */
  724.  
  725. int
  726. symbolic_operand (op, mode)
  727.      register rtx op;
  728.      enum machine_mode mode;
  729. {
  730.   switch (GET_CODE (op))
  731.     {
  732.     case SYMBOL_REF:
  733.     case LABEL_REF:
  734.       return 1;
  735.  
  736.     case CONST:
  737.       op = XEXP (op, 0);
  738.       return ((GET_CODE (XEXP (op, 0)) == SYMBOL_REF
  739.            || GET_CODE (XEXP (op, 0)) == LABEL_REF)
  740.           && GET_CODE (XEXP (op, 1)) == CONST_INT);
  741.  
  742. #if 0 /* Deleted, with corresponding change in m68k.h,
  743.      so as to fit the specs.  No CONST_DOUBLE is ever symbolic.  */
  744.     case CONST_DOUBLE:
  745.       return GET_MODE (op) == mode;
  746. #endif
  747.  
  748.     default:
  749.       return 0;
  750.     }
  751. }
  752.  
  753.  
  754. /* Legitimize PIC addresses.  If the address is already
  755.    position-independent, we return ORIG.  Newly generated
  756.    position-independent addresses go to REG.  If we need more
  757.    than one register, we lose.  
  758.  
  759.    An address is legitimized by making an indirect reference
  760.    through the Global Offset Table with the name of the symbol
  761.    used as an offset.  
  762.  
  763.    The assembler and linker are responsible for placing the 
  764.    address of the symbol in the GOT.  The function prologue
  765.    is responsible for initializing a5 to the starting address
  766.    of the GOT.
  767.  
  768.    The assembler is also responsible for translating a symbol name
  769.    into a constant displacement from the start of the GOT.  
  770.  
  771.    A quick example may make things a little clearer:
  772.  
  773.    When not generating PIC code to store the value 12345 into _foo
  774.    we would generate the following code:
  775.  
  776.     movel #12345, _foo
  777.  
  778.    When generating PIC two transformations are made.  First, the compiler
  779.    loads the address of foo into a register.  So the first transformation makes:
  780.  
  781.     lea    _foo, a0
  782.     movel   #12345, a0@
  783.  
  784.    The code in movsi will intercept the lea instruction and call this
  785.    routine which will transform the instructions into:
  786.  
  787.     movel   a5@(_foo:w), a0
  788.     movel   #12345, a0@
  789.    
  790.  
  791.    That (in a nutshell) is how *all* symbol and label references are 
  792.    handled.  */
  793.  
  794. rtx
  795. legitimize_pic_address (orig, mode, reg)
  796.      rtx orig, reg;
  797.      enum machine_mode mode;
  798. {
  799.   rtx pic_ref = orig;
  800.  
  801.   /* First handle a simple SYMBOL_REF or LABEL_REF */
  802.   if (GET_CODE (orig) == SYMBOL_REF || GET_CODE (orig) == LABEL_REF)
  803.     {
  804. #ifdef LEGITIMATE_BASEREL_OPERAND_P
  805.       if (LEGITIMATE_BASEREL_OPERAND_P (orig))
  806.     return orig;
  807. #endif
  808.  
  809.       if (reg == 0)
  810.     abort ();
  811.  
  812.       if (flag_pic == 3)
  813.         pic_ref = gen_rtx (PLUS, Pmode, pic_offset_table_rtx, orig);
  814.       else
  815.         pic_ref = gen_rtx (MEM, Pmode,
  816.                gen_rtx (PLUS, Pmode,
  817.                     pic_offset_table_rtx, orig));
  818.       current_function_uses_pic_offset_table = 1;
  819.       RTX_UNCHANGING_P (pic_ref) = 1;
  820.       emit_move_insn (reg, pic_ref);
  821.       return reg;
  822.     }
  823.   else if (GET_CODE (orig) == CONST)
  824.     {
  825.       rtx base, offset;
  826.  
  827.       /* Make sure this is CONST has not already been legitimized */
  828.       if (GET_CODE (XEXP (orig, 0)) == PLUS
  829.       && XEXP (XEXP (orig, 0), 0) == pic_offset_table_rtx)
  830.     return orig;
  831.  
  832.       if (reg == 0)
  833.     abort ();
  834.  
  835.       /* legitimize both operands of the PLUS */
  836.       if (GET_CODE (XEXP (orig, 0)) == PLUS)
  837.     {
  838.       base = legitimize_pic_address (XEXP (XEXP (orig, 0), 0), Pmode, reg);
  839.       orig = legitimize_pic_address (XEXP (XEXP (orig, 0), 1), Pmode,
  840.                      base == reg ? 0 : reg);
  841.     }
  842.       else abort ();
  843.  
  844.       if (GET_CODE (orig) == CONST_INT)
  845.     return plus_constant_for_output (base, INTVAL (orig));
  846.       pic_ref = gen_rtx (PLUS, Pmode, base, orig);
  847.       /* Likewise, should we set special REG_NOTEs here?  */
  848.     }
  849.   return pic_ref;
  850. }
  851.  
  852.  
  853. /* Return the best assembler insn template
  854.    for moving operands[1] into operands[0] as a fullword.  */
  855.  
  856. static char *
  857. singlemove_string (operands)
  858.      rtx *operands;
  859. {
  860. #ifdef SUPPORT_SUN_FPA
  861.   if (FPA_REG_P (operands[0]) || FPA_REG_P (operands[1]))
  862.     return "fpmoves %1,%0";
  863. #endif
  864.   if (DATA_REG_P (operands[0])
  865.       && GET_CODE (operands[1]) == CONST_INT
  866.       && INTVAL (operands[1]) < 128
  867.       && INTVAL (operands[1]) >= -128)
  868.     {
  869. #if defined (MOTOROLA) && !defined (CRDS)
  870.       return "moveq%.l %1,%0";
  871. #else
  872.       return "moveq %1,%0";
  873. #endif
  874.     }
  875.   if (operands[1] != const0_rtx)
  876.     return "move%.l %1,%0";
  877.   if (! ADDRESS_REG_P (operands[0]))
  878.     return "clr%.l %0";
  879.   return "sub%.l %0,%0";
  880. }
  881.  
  882.  
  883. /* Output assembler code to perform a doubleword move insn
  884.    with operands OPERANDS.  */
  885.  
  886. char *
  887. output_move_double (operands)
  888.      rtx *operands;
  889. {
  890.   enum
  891.     {
  892.       REGOP, OFFSOP, MEMOP, PUSHOP, POPOP, CNSTOP, RNDOP
  893.     } optype0, optype1;
  894.   rtx latehalf[2];
  895.   rtx middlehalf[2];
  896.   rtx xops[2];
  897.   rtx addreg0 = 0, addreg1 = 0;
  898.   int dest_overlapped_low = 0;
  899.   int size = GET_MODE_SIZE (GET_MODE (operands[0]));
  900.  
  901.   middlehalf[0] = 0;
  902.   middlehalf[1] = 0;
  903.  
  904.   /* First classify both operands.  */
  905.  
  906.   if (REG_P (operands[0]))
  907.     optype0 = REGOP;
  908.   else if (offsettable_memref_p (operands[0]))
  909.     optype0 = OFFSOP;
  910.   else if (GET_CODE (XEXP (operands[0], 0)) == POST_INC)
  911.     optype0 = POPOP;
  912.   else if (GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)
  913.     optype0 = PUSHOP;
  914.   else if (GET_CODE (operands[0]) == MEM)
  915.     optype0 = MEMOP;
  916.   else
  917.     optype0 = RNDOP;
  918.  
  919.   if (REG_P (operands[1]))
  920.     optype1 = REGOP;
  921.   else if (CONSTANT_P (operands[1]))
  922.     optype1 = CNSTOP;
  923.   else if (offsettable_memref_p (operands[1]))
  924.     optype1 = OFFSOP;
  925.   else if (GET_CODE (XEXP (operands[1], 0)) == POST_INC)
  926.     optype1 = POPOP;
  927.   else if (GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)
  928.     optype1 = PUSHOP;
  929.   else if (GET_CODE (operands[1]) == MEM)
  930.     optype1 = MEMOP;
  931.   else
  932.     optype1 = RNDOP;
  933.  
  934.   /* Check for the cases that the operand constraints are not
  935.      supposed to allow to happen.  Abort if we get one,
  936.      because generating code for these cases is painful.  */
  937.  
  938.   if (optype0 == RNDOP || optype1 == RNDOP)
  939.     abort ();
  940.  
  941.   /* If one operand is decrementing and one is incrementing
  942.      decrement the former register explicitly
  943.      and change that operand into ordinary indexing.  */
  944.  
  945.   if (optype0 == PUSHOP && optype1 == POPOP)
  946.     {
  947.       operands[0] = XEXP (XEXP (operands[0], 0), 0);
  948.       if (size == 12)
  949.         output_asm_insn ("sub%.l %#12,%0", operands);
  950.       else
  951.         output_asm_insn ("subq%.l %#8,%0", operands);
  952.       if (GET_MODE (operands[1]) == XFmode)
  953.     operands[0] = gen_rtx (MEM, XFmode, operands[0]);
  954.       else if (GET_MODE (operands[0]) == DFmode)
  955.     operands[0] = gen_rtx (MEM, DFmode, operands[0]);
  956.       else
  957.     operands[0] = gen_rtx (MEM, DImode, operands[0]);
  958.       optype0 = OFFSOP;
  959.     }
  960.   if (optype0 == POPOP && optype1 == PUSHOP)
  961.     {
  962.       operands[1] = XEXP (XEXP (operands[1], 0), 0);
  963.       if (size == 12)
  964.         output_asm_insn ("sub%.l %#12,%1", operands);
  965.       else
  966.         output_asm_insn ("subq%.l %#8,%1", operands);
  967.       if (GET_MODE (operands[1]) == XFmode)
  968.     operands[1] = gen_rtx (MEM, XFmode, operands[1]);
  969.       else if (GET_MODE (operands[1]) == DFmode)
  970.     operands[1] = gen_rtx (MEM, DFmode, operands[1]);
  971.       else
  972.     operands[1] = gen_rtx (MEM, DImode, operands[1]);
  973.       optype1 = OFFSOP;
  974.     }
  975.  
  976.   /* If an operand is an unoffsettable memory ref, find a register
  977.      we can increment temporarily to make it refer to the second word.  */
  978.  
  979.   if (optype0 == MEMOP)
  980.     addreg0 = find_addr_reg (XEXP (operands[0], 0));
  981.  
  982.   if (optype1 == MEMOP)
  983.     addreg1 = find_addr_reg (XEXP (operands[1], 0));
  984.  
  985.   /* Ok, we can do one word at a time.
  986.      Normally we do the low-numbered word first,
  987.      but if either operand is autodecrementing then we
  988.      do the high-numbered word first.
  989.  
  990.      In either case, set up in LATEHALF the operands to use
  991.      for the high-numbered word and in some cases alter the
  992.      operands in OPERANDS to be suitable for the low-numbered word.  */
  993.  
  994.   if (size == 12)
  995.     {
  996.       if (optype0 == REGOP)
  997.     {
  998.       latehalf[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 2);
  999.       middlehalf[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  1000.     }
  1001.       else if (optype0 == OFFSOP)
  1002.     {
  1003.       middlehalf[0] = adj_offsettable_operand (operands[0], 4);
  1004.       latehalf[0] = adj_offsettable_operand (operands[0], size - 4);
  1005.     }
  1006.       else
  1007.     {
  1008.       middlehalf[0] = operands[0];
  1009.       latehalf[0] = operands[0];
  1010.     }
  1011.  
  1012.       if (optype1 == REGOP)
  1013.     {
  1014.       latehalf[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 2);
  1015.       middlehalf[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
  1016.     }
  1017.       else if (optype1 == OFFSOP)
  1018.     {
  1019.       middlehalf[1] = adj_offsettable_operand (operands[1], 4);
  1020.       latehalf[1] = adj_offsettable_operand (operands[1], size - 4);
  1021.     }
  1022.       else if (optype1 == CNSTOP)
  1023.     {
  1024.       if (GET_CODE (operands[1]) == CONST_DOUBLE)
  1025.         {
  1026.           REAL_VALUE_TYPE r;
  1027.           long l[3];
  1028.  
  1029.           REAL_VALUE_FROM_CONST_DOUBLE (r, operands[1]);
  1030.           REAL_VALUE_TO_TARGET_LONG_DOUBLE (r, l);
  1031.           operands[1] = GEN_INT (l[0]);
  1032.           middlehalf[1] = GEN_INT (l[1]);
  1033.           latehalf[1] = GEN_INT (l[2]);
  1034.         }
  1035.       else if (CONSTANT_P (operands[1]))
  1036.         {
  1037.           /* actually, no non-CONST_DOUBLE constant should ever
  1038.          appear here.  */
  1039.           abort ();
  1040.           if (GET_CODE (operands[1]) == CONST_INT && INTVAL (operands[1]) < 0)
  1041.         latehalf[1] = constm1_rtx;
  1042.           else
  1043.         latehalf[1] = const0_rtx;
  1044.         }
  1045.     }
  1046.       else
  1047.     {
  1048.       middlehalf[1] = operands[1];
  1049.       latehalf[1] = operands[1];
  1050.     }
  1051.     }
  1052.   else
  1053.     /* size is not 12: */
  1054.     {
  1055.       if (optype0 == REGOP)
  1056.     latehalf[0] = gen_rtx (REG, SImode, REGNO (operands[0]) + 1);
  1057.       else if (optype0 == OFFSOP)
  1058.     latehalf[0] = adj_offsettable_operand (operands[0], size - 4);
  1059.       else
  1060.     latehalf[0] = operands[0];
  1061.  
  1062.       if (optype1 == REGOP)
  1063.     latehalf[1] = gen_rtx (REG, SImode, REGNO (operands[1]) + 1);
  1064.       else if (optype1 == OFFSOP)
  1065.     latehalf[1] = adj_offsettable_operand (operands[1], size - 4);
  1066.       else if (optype1 == CNSTOP)
  1067.     split_double (operands[1], &operands[1], &latehalf[1]);
  1068.       else
  1069.     latehalf[1] = operands[1];
  1070.     }
  1071.  
  1072.   /* If insn is effectively movd N(sp),-(sp) then we will do the
  1073.      high word first.  We should use the adjusted operand 1 (which is N+4(sp))
  1074.      for the low word as well, to compensate for the first decrement of sp.  */
  1075.   if (optype0 == PUSHOP
  1076.       && REGNO (XEXP (XEXP (operands[0], 0), 0)) == STACK_POINTER_REGNUM
  1077.       && reg_overlap_mentioned_p (stack_pointer_rtx, operands[1]))
  1078.     operands[1] = middlehalf[1] = latehalf[1];
  1079.  
  1080.   /* For (set (reg:DI N) (mem:DI ... (reg:SI N) ...)),
  1081.      if the upper part of reg N does not appear in the MEM, arrange to
  1082.      emit the move late-half first.  Otherwise, compute the MEM address
  1083.      into the upper part of N and use that as a pointer to the memory
  1084.      operand.  */
  1085.   if (optype0 == REGOP
  1086.       && (optype1 == OFFSOP || optype1 == MEMOP))
  1087.     {
  1088.       rtx testlow = gen_rtx (REG, SImode, REGNO (operands[0]));
  1089.  
  1090.       if (reg_overlap_mentioned_p (testlow, XEXP (operands[1], 0))
  1091.       && reg_overlap_mentioned_p (latehalf[0], XEXP (operands[1], 0)))
  1092.     {
  1093.       /* If both halves of dest are used in the src memory address,
  1094.          compute the address into latehalf of dest.
  1095.          Note that this can't happen if the dest is two data regs.  */
  1096. compadr:
  1097.       xops[0] = latehalf[0];
  1098.       xops[1] = XEXP (operands[1], 0);
  1099.       output_asm_insn ("lea %a1,%0", xops);
  1100.       if( GET_MODE (operands[1]) == XFmode )
  1101.         {
  1102.           operands[1] = gen_rtx (MEM, XFmode, latehalf[0]);
  1103.           middlehalf[1] = adj_offsettable_operand (operands[1], size-8);
  1104.           latehalf[1] = adj_offsettable_operand (operands[1], size-4);
  1105.         }
  1106.       else
  1107.         {
  1108.           operands[1] = gen_rtx (MEM, DImode, latehalf[0]);
  1109.           latehalf[1] = adj_offsettable_operand (operands[1], size-4);
  1110.         }
  1111.     }
  1112.       else if (size == 12
  1113.            && reg_overlap_mentioned_p (middlehalf[0],
  1114.                        XEXP (operands[1], 0)))
  1115.     {
  1116.       /* Check for two regs used by both source and dest.
  1117.          Note that this can't happen if the dest is all data regs.
  1118.          It can happen if the dest is d6, d7, a0.
  1119.          But in that case, latehalf is an addr reg, so
  1120.          the code at compadr does ok.  */
  1121.  
  1122.       if (reg_overlap_mentioned_p (testlow, XEXP (operands[1], 0))
  1123.           || reg_overlap_mentioned_p (latehalf[0], XEXP (operands[1], 0)))
  1124.         goto compadr;
  1125.  
  1126.       /* JRV says this can't happen: */
  1127.       if (addreg0 || addreg1)
  1128.         abort ();
  1129.  
  1130.       /* Only the middle reg conflicts; simply put it last. */
  1131.       output_asm_insn (singlemove_string (operands), operands);
  1132.       output_asm_insn (singlemove_string (latehalf), latehalf);
  1133.       output_asm_insn (singlemove_string (middlehalf), middlehalf);
  1134.       return "";
  1135.     }
  1136.       else if (reg_overlap_mentioned_p (testlow, XEXP (operands[1], 0)))
  1137.     /* If the low half of dest is mentioned in the source memory
  1138.        address, the arrange to emit the move late half first.  */
  1139.     dest_overlapped_low = 1;
  1140.     }
  1141.  
  1142.   /* If one or both operands autodecrementing,
  1143.      do the two words, high-numbered first.  */
  1144.  
  1145.   /* Likewise,  the first move would clobber the source of the second one,
  1146.      do them in the other order.  This happens only for registers;
  1147.      such overlap can't happen in memory unless the user explicitly
  1148.      sets it up, and that is an undefined circumstance.  */
  1149.  
  1150.   if (optype0 == PUSHOP || optype1 == PUSHOP
  1151.       || (optype0 == REGOP && optype1 == REGOP
  1152.       && ((middlehalf[1] && REGNO (operands[0]) == REGNO (middlehalf[1]))
  1153.           || REGNO (operands[0]) == REGNO (latehalf[1])))
  1154.       || dest_overlapped_low)
  1155.     {
  1156.       /* Make any unoffsettable addresses point at high-numbered word.  */
  1157.       if (addreg0)
  1158.     {
  1159.       if (size == 12)
  1160.         output_asm_insn ("addql %#8,%0", &addreg0);
  1161.       else
  1162.         output_asm_insn ("addql %#4,%0", &addreg0);
  1163.     }
  1164.       if (addreg1)
  1165.     {
  1166.       if (size == 12)
  1167.         output_asm_insn ("addql %#8,%0", &addreg1);
  1168.       else
  1169.         output_asm_insn ("addql %#4,%0", &addreg1);
  1170.     }
  1171.  
  1172.       /* Do that word.  */
  1173.       output_asm_insn (singlemove_string (latehalf), latehalf);
  1174.  
  1175.       /* Undo the adds we just did.  */
  1176.       if (addreg0)
  1177.     output_asm_insn ("subql %#4,%0", &addreg0);
  1178.       if (addreg1)
  1179.     output_asm_insn ("subql %#4,%0", &addreg1);
  1180.  
  1181.       if (size == 12)
  1182.     {
  1183.       output_asm_insn (singlemove_string (middlehalf), middlehalf);
  1184.       if (addreg0)
  1185.         output_asm_insn ("subql %#4,%0", &addreg0);
  1186.       if (addreg1)
  1187.         output_asm_insn ("subql %#4,%0", &addreg1);
  1188.     }
  1189.  
  1190.       /* Do low-numbered word.  */
  1191.       return singlemove_string (operands);
  1192.     }
  1193.  
  1194.   /* Normal case: do the two words, low-numbered first.  */
  1195.  
  1196.   output_asm_insn (singlemove_string (operands), operands);
  1197.  
  1198.   /* Do the middle one of the three words for long double */
  1199.   if (size == 12)
  1200.     {
  1201.       if (addreg0)
  1202.     output_asm_insn ("addql %#4,%0", &addreg0);
  1203.       if (addreg1)
  1204.     output_asm_insn ("addql %#4,%0", &addreg1);
  1205.  
  1206.       output_asm_insn (singlemove_string (middlehalf), middlehalf);
  1207.     }
  1208.  
  1209.   /* Make any unoffsettable addresses point at high-numbered word.  */
  1210.   if (addreg0)
  1211.     output_asm_insn ("addql %#4,%0", &addreg0);
  1212.   if (addreg1)
  1213.     output_asm_insn ("addql %#4,%0", &addreg1);
  1214.  
  1215.   /* Do that word.  */
  1216.   output_asm_insn (singlemove_string (latehalf), latehalf);
  1217.  
  1218.   /* Undo the adds we just did.  */
  1219.   if (addreg0)
  1220.     {
  1221.       if (size == 12)
  1222.         output_asm_insn ("subql %#8,%0", &addreg0);
  1223.       else
  1224.         output_asm_insn ("subql %#4,%0", &addreg0);
  1225.     }
  1226.   if (addreg1)
  1227.     {
  1228.       if (size == 12)
  1229.         output_asm_insn ("subql %#8,%0", &addreg1);
  1230.       else
  1231.         output_asm_insn ("subql %#4,%0", &addreg1);
  1232.     }
  1233.  
  1234.   return "";
  1235. }
  1236.  
  1237. /* Return a REG that occurs in ADDR with coefficient 1.
  1238.    ADDR can be effectively incremented by incrementing REG.  */
  1239.  
  1240. static rtx
  1241. find_addr_reg (addr)
  1242.      rtx addr;
  1243. {
  1244.   while (GET_CODE (addr) == PLUS)
  1245.     {
  1246.       if (GET_CODE (XEXP (addr, 0)) == REG)
  1247.     addr = XEXP (addr, 0);
  1248.       else if (GET_CODE (XEXP (addr, 1)) == REG)
  1249.     addr = XEXP (addr, 1);
  1250.       else if (CONSTANT_P (XEXP (addr, 0)))
  1251.     addr = XEXP (addr, 1);
  1252.       else if (CONSTANT_P (XEXP (addr, 1)))
  1253.     addr = XEXP (addr, 0);
  1254.       else
  1255.     abort ();
  1256.     }
  1257.   if (GET_CODE (addr) == REG)
  1258.     return addr;
  1259.   abort ();
  1260. }
  1261.  
  1262. /* Store in cc_status the expressions that the condition codes will
  1263.    describe after execution of an instruction whose pattern is EXP.
  1264.    Do not alter them if the instruction would not alter the cc's.  */
  1265.  
  1266. /* On the 68000, all the insns to store in an address register fail to
  1267.    set the cc's.  However, in some cases these instructions can make it
  1268.    possibly invalid to use the saved cc's.  In those cases we clear out
  1269.    some or all of the saved cc's so they won't be used.  */
  1270.  
  1271. notice_update_cc (exp, insn)
  1272.      rtx exp;
  1273.      rtx insn;
  1274. {
  1275.   /* If the cc is being set from the fpa and the expression is not an
  1276.      explicit floating point test instruction (which has code to deal with
  1277.      this), reinit the CC.  */
  1278.   if (((cc_status.value1 && FPA_REG_P (cc_status.value1))
  1279.        || (cc_status.value2 && FPA_REG_P (cc_status.value2)))
  1280.       && !(GET_CODE (exp) == PARALLEL
  1281.        && GET_CODE (XVECEXP (exp, 0, 0)) == SET
  1282.        && XEXP (XVECEXP (exp, 0, 0), 0) == cc0_rtx))
  1283.     {
  1284.       CC_STATUS_INIT; 
  1285.     }
  1286.   else if (GET_CODE (exp) == SET)
  1287.     {
  1288.       if (GET_CODE (SET_SRC (exp)) == CALL)
  1289.     {
  1290.       CC_STATUS_INIT; 
  1291.     }
  1292.       else if (ADDRESS_REG_P (SET_DEST (exp)))
  1293.     {
  1294.       if (cc_status.value1
  1295.           && reg_overlap_mentioned_p (SET_DEST (exp), cc_status.value1))
  1296.         cc_status.value1 = 0;
  1297.       if (cc_status.value2
  1298.           && reg_overlap_mentioned_p (SET_DEST (exp), cc_status.value2))
  1299.         cc_status.value2 = 0; 
  1300.     }
  1301.       else if (!FP_REG_P (SET_DEST (exp))
  1302.            && SET_DEST (exp) != cc0_rtx
  1303.            && (FP_REG_P (SET_SRC (exp))
  1304.            || GET_CODE (SET_SRC (exp)) == FIX
  1305.            || GET_CODE (SET_SRC (exp)) == FLOAT_TRUNCATE
  1306.            || GET_CODE (SET_SRC (exp)) == FLOAT_EXTEND))
  1307.     {
  1308.       CC_STATUS_INIT; 
  1309.     }
  1310.       /* A pair of move insns doesn't produce a useful overall cc.  */
  1311.       else if (!FP_REG_P (SET_DEST (exp))
  1312.            && !FP_REG_P (SET_SRC (exp))
  1313.            && GET_MODE_SIZE (GET_MODE (SET_SRC (exp))) > 4
  1314.            && (GET_CODE (SET_SRC (exp)) == REG
  1315.            || GET_CODE (SET_SRC (exp)) == MEM
  1316.            || GET_CODE (SET_SRC (exp)) == CONST_DOUBLE))
  1317.     {
  1318.       CC_STATUS_INIT; 
  1319.     }
  1320.       else if (GET_CODE (SET_SRC (exp)) == CALL)
  1321.     {
  1322.       CC_STATUS_INIT; 
  1323.     }
  1324.       else if (XEXP (exp, 0) != pc_rtx)
  1325.     {
  1326.       cc_status.flags = 0;
  1327.       cc_status.value1 = XEXP (exp, 0);
  1328.       cc_status.value2 = XEXP (exp, 1);
  1329.     }
  1330.     }
  1331.   else if (GET_CODE (exp) == PARALLEL
  1332.        && GET_CODE (XVECEXP (exp, 0, 0)) == SET)
  1333.     {
  1334.       if (ADDRESS_REG_P (XEXP (XVECEXP (exp, 0, 0), 0)))
  1335.     CC_STATUS_INIT;
  1336.       else if (XEXP (XVECEXP (exp, 0, 0), 0) != pc_rtx)
  1337.     {
  1338.       cc_status.flags = 0;
  1339.       cc_status.value1 = XEXP (XVECEXP (exp, 0, 0), 0);
  1340.       cc_status.value2 = XEXP (XVECEXP (exp, 0, 0), 1);
  1341.     }
  1342.     }
  1343.   else
  1344.     CC_STATUS_INIT;
  1345.   if (cc_status.value2 != 0
  1346.       && ADDRESS_REG_P (cc_status.value2)
  1347.       && GET_MODE (cc_status.value2) == QImode)
  1348.     CC_STATUS_INIT;
  1349.   if (cc_status.value2 != 0
  1350.       && !(cc_status.value1 && FPA_REG_P (cc_status.value1)))
  1351.     switch (GET_CODE (cc_status.value2))
  1352.       {
  1353.       case PLUS: case MINUS: case MULT:
  1354.       case DIV: case UDIV: case MOD: case UMOD: case NEG:
  1355.       case ASHIFT: case LSHIFT: case ASHIFTRT: case LSHIFTRT:
  1356.       case ROTATE: case ROTATERT:
  1357.     if (GET_MODE (cc_status.value2) != VOIDmode)
  1358.       cc_status.flags |= CC_NO_OVERFLOW;
  1359.     break;
  1360.       case ZERO_EXTEND:
  1361.     /* (SET r1 (ZERO_EXTEND r2)) on this machine
  1362.        ends with a move insn moving r2 in r2's mode.
  1363.        Thus, the cc's are set for r2.
  1364.        This can set N bit spuriously. */
  1365.     cc_status.flags |= CC_NOT_NEGATIVE; 
  1366.       }
  1367.   if (cc_status.value1 && GET_CODE (cc_status.value1) == REG
  1368.       && cc_status.value2
  1369.       && reg_overlap_mentioned_p (cc_status.value1, cc_status.value2))
  1370.     cc_status.value2 = 0;
  1371.   if (((cc_status.value1 && FP_REG_P (cc_status.value1))
  1372.        || (cc_status.value2 && FP_REG_P (cc_status.value2)))
  1373.       && !((cc_status.value1 && FPA_REG_P (cc_status.value1))
  1374.        || (cc_status.value2 && FPA_REG_P (cc_status.value2))))
  1375.     cc_status.flags = CC_IN_68881;
  1376. }
  1377.  
  1378. char *
  1379. output_move_const_double (operands)
  1380.      rtx *operands;
  1381. {
  1382. #ifdef SUPPORT_SUN_FPA
  1383.   if (TARGET_FPA && FPA_REG_P (operands[0]))
  1384.     {
  1385.       int code = standard_sun_fpa_constant_p (operands[1]);
  1386.  
  1387.       if (code != 0)
  1388.     {
  1389.       static char buf[40];
  1390.  
  1391.       sprintf (buf, "fpmove%%.d %%%%%d,%%0", code & 0x1ff);
  1392.       return buf;
  1393.     }
  1394.       return "fpmove%.d %1,%0";
  1395.     }
  1396.   else
  1397. #endif
  1398.     {
  1399.       int code = standard_68881_constant_p (operands[1]);
  1400.  
  1401.       if (code != 0)
  1402.     {
  1403.       static char buf[40];
  1404.  
  1405.       sprintf (buf, "fmovecr %%#0x%x,%%0", code & 0xff);
  1406.       return buf;
  1407.     }
  1408.       return "fmove%.d %1,%0";
  1409.     }
  1410. }
  1411.  
  1412. char *
  1413. output_move_const_single (operands)
  1414.      rtx *operands;
  1415. {
  1416. #ifdef SUPPORT_SUN_FPA
  1417.   if (TARGET_FPA)
  1418.     {
  1419.       int code = standard_sun_fpa_constant_p (operands[1]);
  1420.  
  1421.       if (code != 0)
  1422.     {
  1423.       static char buf[40];
  1424.  
  1425.       sprintf (buf, "fpmove%%.s %%%%%d,%%0", code & 0x1ff);
  1426.       return buf;
  1427.     }
  1428.       return "fpmove%.s %1,%0";
  1429.     }
  1430.   else
  1431. #endif /* defined SUPPORT_SUN_FPA */
  1432.     {
  1433.       int code = standard_68881_constant_p (operands[1]);
  1434.  
  1435.       if (code != 0)
  1436.     {
  1437.       static char buf[40];
  1438.  
  1439.       sprintf (buf, "fmovecr %%#0x%x,%%0", code & 0xff);
  1440.       return buf;
  1441.     }
  1442.       return "fmove%.s %f1,%0";
  1443.     }
  1444. }
  1445.  
  1446. /* Return nonzero if X, a CONST_DOUBLE, has a value that we can get
  1447.    from the "fmovecr" instruction.
  1448.    The value, anded with 0xff, gives the code to use in fmovecr
  1449.    to get the desired constant.  */
  1450.  
  1451. /* This code has been fixed for cross-compilation. */
  1452.   
  1453. static int inited_68881_table = 0;
  1454.  
  1455. char *strings_68881[7] = {
  1456.   "0.0",
  1457.   "1.0",
  1458.   "10.0",
  1459.   "100.0",
  1460.   "10000.0",
  1461.   "1e8",
  1462.   "1e16"
  1463.   };
  1464.  
  1465. int codes_68881[7] = {
  1466.   0x0f,
  1467.   0x32,
  1468.   0x33,
  1469.   0x34,
  1470.   0x35,
  1471.   0x36,
  1472.   0x37
  1473.   };
  1474.  
  1475. REAL_VALUE_TYPE values_68881[7];
  1476.  
  1477. /* Set up values_68881 array by converting the decimal values
  1478.    strings_68881 to binary.   */
  1479.  
  1480. void
  1481. init_68881_table ()
  1482. {
  1483.   int i;
  1484.   REAL_VALUE_TYPE r;
  1485.   enum machine_mode mode;
  1486.  
  1487.   mode = DFmode;
  1488.   for (i = 0; i < 7; i++)
  1489.     {
  1490.       if (i == 6)
  1491.         mode = SFmode;
  1492.       r = REAL_VALUE_ATOF (strings_68881[i], mode);
  1493.       values_68881[i] = r;
  1494.     }
  1495.   inited_68881_table = 1;
  1496. }
  1497.  
  1498. int
  1499. standard_68881_constant_p (x)
  1500.      rtx x;
  1501. {
  1502.   REAL_VALUE_TYPE r;
  1503.   int i;
  1504.   enum machine_mode mode;
  1505.  
  1506.   /* fmovecr must be emulated on the 68040, so it shouldn't be used at all. */
  1507.   if (TARGET_68040)
  1508.     return 0;
  1509.  
  1510. #ifndef REAL_ARITHMETIC
  1511. #if HOST_FLOAT_FORMAT != TARGET_FLOAT_FORMAT
  1512.   if (! flag_pretend_float)
  1513.     return 0;
  1514. #endif
  1515. #endif
  1516.  
  1517.   if (! inited_68881_table)
  1518.     init_68881_table ();
  1519.  
  1520.   REAL_VALUE_FROM_CONST_DOUBLE (r, x);
  1521.  
  1522.   for (i = 0; i < 6; i++)
  1523.     {
  1524.       if (REAL_VALUES_EQUAL (r, values_68881[i]))
  1525.         return (codes_68881[i]);
  1526.     }
  1527.   
  1528.   if (GET_MODE (x) == SFmode)
  1529.     return 0;
  1530.  
  1531.   if (REAL_VALUES_EQUAL (r, values_68881[6]))
  1532.     return (codes_68881[6]);
  1533.  
  1534.   /* larger powers of ten in the constants ram are not used
  1535.      because they are not equal to a `double' C constant.  */
  1536.   return 0;
  1537. }
  1538.  
  1539. /* If X is a floating-point constant, return the logarithm of X base 2,
  1540.    or 0 if X is not a power of 2.  */
  1541.  
  1542. int
  1543. floating_exact_log2 (x)
  1544.      rtx x;
  1545. {
  1546.   REAL_VALUE_TYPE r, r1;
  1547.   int i;
  1548.  
  1549. #ifndef REAL_ARITHMETIC
  1550. #if HOST_FLOAT_FORMAT != TARGET_FLOAT_FORMAT
  1551.   if (! flag_pretend_float)
  1552.     return 0;
  1553. #endif
  1554. #endif
  1555.  
  1556.   REAL_VALUE_FROM_CONST_DOUBLE (r, x);
  1557.  
  1558.   if (REAL_VALUES_LESS (r, dconst0))
  1559.     return 0;
  1560.  
  1561.   r1 = dconst1;
  1562.   i = 0;
  1563.   while (REAL_VALUES_LESS (r1, r))
  1564.     {
  1565.       r1 = REAL_VALUE_LDEXP (dconst1, i);
  1566.       if (REAL_VALUES_EQUAL (r1, r))
  1567.         return i;
  1568.       i = i + 1;
  1569.     }
  1570.   return 0;
  1571. }
  1572.  
  1573. #ifdef SUPPORT_SUN_FPA
  1574. /* Return nonzero if X, a CONST_DOUBLE, has a value that we can get
  1575.    from the Sun FPA's constant RAM.
  1576.    The value returned, anded with 0x1ff, gives the code to use in fpmove
  1577.    to get the desired constant. */
  1578.  
  1579. static int inited_FPA_table = 0;
  1580.  
  1581. char *strings_FPA[38] = {
  1582. /* small rationals */
  1583.   "0.0",
  1584.   "1.0",
  1585.   "0.5",
  1586.   "-1.0",
  1587.   "2.0",
  1588.   "3.0",
  1589.   "4.0",
  1590.   "8.0",
  1591.   "0.25",
  1592.   "0.125",
  1593.   "10.0",
  1594.   "-0.5",
  1595. /* Decimal equivalents of double precision values */
  1596.   "2.718281828459045091", /* D_E */
  1597.   "6.283185307179586477", /* 2 pi */
  1598.   "3.141592653589793116", /* D_PI */
  1599.   "1.570796326794896619", /* pi/2 */
  1600.   "1.414213562373095145", /* D_SQRT2 */
  1601.   "0.7071067811865475244", /* 1/sqrt(2) */
  1602.   "-1.570796326794896619", /* -pi/2 */
  1603.   "1.442695040888963387", /* D_LOG2ofE */
  1604.   "3.321928024887362182", /* D_LOG2of10 */
  1605.   "0.6931471805599452862", /* D_LOGEof2 */
  1606.   "2.302585092994045901", /* D_LOGEof10 */
  1607.   "0.3010299956639811980", /* D_LOG10of2 */
  1608.   "0.4342944819032518167", /* D_LOG10ofE */
  1609. /* Decimal equivalents of single precision values */
  1610.   "2.718281745910644531", /* S_E */
  1611.   "6.283185307179586477", /* 2 pi */
  1612.   "3.141592741012573242", /* S_PI */
  1613.   "1.570796326794896619", /* pi/2 */
  1614.   "1.414213538169860840", /* S_SQRT2 */
  1615.   "0.7071067811865475244", /* 1/sqrt(2) */
  1616.   "-1.570796326794896619", /* -pi/2 */
  1617.   "1.442695021629333496", /* S_LOG2ofE */
  1618.   "3.321928024291992188", /* S_LOG2of10 */
  1619.   "0.6931471824645996094", /* S_LOGEof2 */
  1620.   "2.302585124969482442", /* S_LOGEof10 */
  1621.   "0.3010300099849700928", /* S_LOG10of2 */
  1622.   "0.4342944920063018799", /* S_LOG10ofE */
  1623. };
  1624.  
  1625.  
  1626. int codes_FPA[38] = {
  1627. /* small rationals */
  1628.   0x200,
  1629.   0xe,
  1630.   0xf,
  1631.   0x10,
  1632.   0x11,
  1633.   0xb1,
  1634.   0x12,
  1635.   0x13,
  1636.   0x15,
  1637.   0x16,
  1638.   0x17,
  1639.   0x2e,
  1640. /* double precision */
  1641.   0x8,
  1642.   0x9,
  1643.   0xa,
  1644.   0xb,
  1645.   0xc,
  1646.   0xd,
  1647.   0x27,
  1648.   0x28,
  1649.   0x29,
  1650.   0x2a,
  1651.   0x2b,
  1652.   0x2c,
  1653.   0x2d,
  1654. /* single precision */
  1655.   0x8,
  1656.   0x9,
  1657.   0xa,
  1658.   0xb,
  1659.   0xc,
  1660.   0xd,
  1661.   0x27,
  1662.   0x28,
  1663.   0x29,
  1664.   0x2a,
  1665.   0x2b,
  1666.   0x2c,
  1667.   0x2d
  1668.   };
  1669.  
  1670. REAL_VALUE_TYPE values_FPA[38];
  1671.  
  1672. /* This code has been fixed for cross-compilation. */
  1673.  
  1674. void
  1675. init_FPA_table ()
  1676. {
  1677.   enum machine_mode mode;
  1678.   int i;
  1679.   REAL_VALUE_TYPE r;
  1680.  
  1681.   mode = DFmode;
  1682.   for (i = 0; i < 38; i++)
  1683.     {
  1684.       if (i == 25)
  1685.         mode = SFmode;
  1686.       r = REAL_VALUE_ATOF (strings_FPA[i], mode);
  1687.       values_FPA[i] = r;
  1688.     }
  1689.   inited_FPA_table = 1;
  1690. }
  1691.  
  1692.  
  1693. int
  1694. standard_sun_fpa_constant_p (x)
  1695.      rtx x;
  1696. {
  1697.   REAL_VALUE_TYPE r;
  1698.   int i;
  1699.  
  1700. #ifndef REAL_ARITHMETIC
  1701. #if HOST_FLOAT_FORMAT != TARGET_FLOAT_FORMAT
  1702.   if (! flag_pretend_float)
  1703.     return 0;
  1704. #endif
  1705. #endif
  1706.  
  1707.   if (! inited_FPA_table)
  1708.     init_FPA_table ();
  1709.  
  1710.   REAL_VALUE_FROM_CONST_DOUBLE (r, x);
  1711.  
  1712.   for (i=0; i<12; i++)
  1713.     {
  1714.       if (REAL_VALUES_EQUAL (r, values_FPA[i]))
  1715.         return (codes_FPA[i]);
  1716.     }
  1717.  
  1718.   if (GET_MODE (x) == SFmode)
  1719.     {
  1720.       for (i=25; i<38; i++)
  1721.         {
  1722.           if (REAL_VALUES_EQUAL (r, values_FPA[i]))
  1723.             return (codes_FPA[i]);
  1724.         }
  1725.     }
  1726.   else
  1727.     {
  1728.       for (i=12; i<25; i++)
  1729.         {
  1730.           if (REAL_VALUES_EQUAL (r, values_FPA[i]))
  1731.             return (codes_FPA[i]);
  1732.         }
  1733.     }
  1734.   return 0x0;
  1735. }
  1736. #endif /* define SUPPORT_SUN_FPA */
  1737.  
  1738. /* A C compound statement to output to stdio stream STREAM the
  1739.    assembler syntax for an instruction operand X.  X is an RTL
  1740.    expression.
  1741.  
  1742.    CODE is a value that can be used to specify one of several ways
  1743.    of printing the operand.  It is used when identical operands
  1744.    must be printed differently depending on the context.  CODE
  1745.    comes from the `%' specification that was used to request
  1746.    printing of the operand.  If the specification was just `%DIGIT'
  1747.    then CODE is 0; if the specification was `%LTR DIGIT' then CODE
  1748.    is the ASCII code for LTR.
  1749.  
  1750.    If X is a register, this macro should print the register's name.
  1751.    The names can be found in an array `reg_names' whose type is
  1752.    `char *[]'.  `reg_names' is initialized from `REGISTER_NAMES'.
  1753.  
  1754.    When the machine description has a specification `%PUNCT' (a `%'
  1755.    followed by a punctuation character), this macro is called with
  1756.    a null pointer for X and the punctuation character for CODE.
  1757.  
  1758.    The m68k specific codes are:
  1759.  
  1760.    '.' for dot needed in Motorola-style opcode names.
  1761.    '-' for an operand pushing on the stack:
  1762.        sp@-, -(sp) or -(%sp) depending on the style of syntax.
  1763.    '+' for an operand pushing on the stack:
  1764.        sp@+, (sp)+ or (%sp)+ depending on the style of syntax.
  1765.    '@' for a reference to the top word on the stack:
  1766.        sp@, (sp) or (%sp) depending on the style of syntax.
  1767.    '#' for an immediate operand prefix (# in MIT and Motorola syntax
  1768.        but & in SGS syntax).
  1769.    '!' for the cc register (used in an `and to cc' insn).
  1770.    '$' for the letter `s' in an op code, but only on the 68040.
  1771.    '&' for the letter `d' in an op code, but only on the 68040.
  1772.    '/' for register prefix needed by longlong.h.
  1773.  
  1774.    'b' for byte insn (no effect, on the Sun; this is for the ISI).
  1775.    'd' to force memory addressing to be absolute, not relative.
  1776.    'f' for float insn (print a CONST_DOUBLE as a float rather than in hex)
  1777.    'w' for FPA insn (print a CONST_DOUBLE as a SunFPA constant rather
  1778.        than directly).  Second part of 'y' below.
  1779.    'x' for float insn (print a CONST_DOUBLE as a float rather than in hex),
  1780.        or print pair of registers as rx:ry.
  1781.    'y' for a FPA insn (print pair of registers as rx:ry).  This also outputs
  1782.        CONST_DOUBLE's as SunFPA constant RAM registers if
  1783.        possible, so it should not be used except for the SunFPA.
  1784.  
  1785.    */
  1786.  
  1787. void
  1788. print_operand (file, op, letter)
  1789.      FILE *file;        /* file to write to */
  1790.      rtx op;            /* operand to print */
  1791.      int letter;        /* %<letter> or 0 */
  1792. {
  1793.   int i;
  1794.  
  1795.   if (letter == '.')
  1796.     {
  1797. #ifdef MOTOROLA
  1798.       asm_fprintf (file, ".");
  1799. #endif
  1800.     }
  1801.   else if (letter == '#')
  1802.     {
  1803.       asm_fprintf (file, "%0I");
  1804.     }
  1805.   else if (letter == '-')
  1806.     {
  1807. #ifdef MOTOROLA
  1808.       asm_fprintf (file, "-(%Rsp)");
  1809. #else
  1810.       asm_fprintf (file, "%Rsp@-");
  1811. #endif
  1812.     }
  1813.   else if (letter == '+')
  1814.     {
  1815. #ifdef MOTOROLA
  1816.       asm_fprintf (file, "(%Rsp)+");
  1817. #else
  1818.       asm_fprintf (file, "%Rsp@+");
  1819. #endif
  1820.     }
  1821.   else if (letter == '@')
  1822.     {
  1823. #ifdef MOTOROLA
  1824.       asm_fprintf (file, "(%Rsp)");
  1825. #else
  1826.       asm_fprintf (file, "%Rsp@");
  1827. #endif
  1828.     }
  1829.   else if (letter == '!')
  1830.     {
  1831.       asm_fprintf (file, "%Rfpcr");
  1832.     }
  1833.   else if (letter == '$')
  1834.     {
  1835.       if (TARGET_68040_ONLY)
  1836.     {
  1837.       fprintf (file, "s");
  1838.     }
  1839.     }
  1840.   else if (letter == '&')
  1841.     {
  1842.       if (TARGET_68040_ONLY)
  1843.     {
  1844.       fprintf (file, "d");
  1845.     }
  1846.     }
  1847.   else if (letter == '/')
  1848.     {
  1849.       asm_fprintf (file, "%R");
  1850.     }
  1851.   else if (GET_CODE (op) == REG)
  1852.     {
  1853.       if (REGNO (op) < 16
  1854.       && (letter == 'y' || letter == 'x')
  1855.       && GET_MODE (op) == DFmode)
  1856.     {
  1857.       fprintf (file, "%s:%s", reg_names[REGNO (op)],
  1858.            reg_names[REGNO (op)+1]);
  1859.     }
  1860.       else
  1861.     {
  1862.       fprintf (file, "%s", reg_names[REGNO (op)]);
  1863.     }
  1864.     }
  1865.   else if (GET_CODE (op) == MEM)
  1866.     {
  1867.       output_address (XEXP (op, 0));
  1868.       if (letter == 'd' && ! TARGET_68020
  1869.       && CONSTANT_ADDRESS_P (XEXP (op, 0))
  1870.       && !(TARGET_PC_REL && GET_CODE (XEXP (op, 0)) == SYMBOL_REF
  1871.            && SYMBOL_REF_FLAG (XEXP (op, 0))
  1872.            && !SYMBOL_REF_USED (XEXP (op, 0)))
  1873.       && !(GET_CODE (XEXP (op, 0)) == CONST_INT
  1874.            && INTVAL (XEXP (op, 0)) < 0x8000
  1875.            && INTVAL (XEXP (op, 0)) >= -0x8000))
  1876.     {
  1877.       fprintf (file, ":l");
  1878.     }
  1879.     }
  1880. #ifdef SUPPORT_SUN_FPA
  1881.   else if ((letter == 'y' || letter == 'w')
  1882.        && GET_CODE (op) == CONST_DOUBLE
  1883.        && (i = standard_sun_fpa_constant_p (op)))
  1884.     {
  1885.       fprintf (file, "%%%d", i & 0x1ff);
  1886.     }
  1887. #endif
  1888.   else if (GET_CODE (op) == CONST_DOUBLE && GET_MODE (op) == SFmode)
  1889.     {
  1890.       REAL_VALUE_TYPE r;
  1891.       REAL_VALUE_FROM_CONST_DOUBLE (r, op);
  1892.       ASM_OUTPUT_FLOAT_OPERAND (letter, file, r);
  1893.     }
  1894.   else if (GET_CODE (op) == CONST_DOUBLE && GET_MODE (op) == XFmode)
  1895.     {
  1896.       REAL_VALUE_TYPE r;
  1897.       REAL_VALUE_FROM_CONST_DOUBLE (r, op);
  1898.       ASM_OUTPUT_LONG_DOUBLE_OPERAND (file, r);
  1899.     }
  1900.   else if (GET_CODE (op) == CONST_DOUBLE && GET_MODE (op) == DFmode)
  1901.     {
  1902.       REAL_VALUE_TYPE r;
  1903.       REAL_VALUE_FROM_CONST_DOUBLE (r, op);
  1904.       ASM_OUTPUT_DOUBLE_OPERAND (file, r);
  1905.     }
  1906.   else
  1907.     {
  1908.       asm_fprintf (file, "%0I"); output_addr_const (file, op);
  1909.     }
  1910. }
  1911.  
  1912.  
  1913. /* A C compound statement to output to stdio stream STREAM the
  1914.    assembler syntax for an instruction operand that is a memory
  1915.    reference whose address is ADDR.  ADDR is an RTL expression.
  1916.  
  1917.    Note that this contains a kludge that knows that the only reason
  1918.    we have an address (plus (label_ref...) (reg...)) when not generating
  1919.    PIC code is in the insn before a tablejump, and we know that m68k.md
  1920.    generates a label LInnn: on such an insn.
  1921.  
  1922.    It is possible for PIC to generate a (plus (label_ref...) (reg...))
  1923.    and we handle that just like we would a (plus (symbol_ref...) (reg...)).
  1924.  
  1925.    Some SGS assemblers have a bug such that "Lnnn-LInnn-2.b(pc,d0.l*2)"
  1926.    fails to assemble.  Luckily "Lnnn(pc,d0.l*2)" produces the results
  1927.    we want.  This difference can be accommodated by using an assembler
  1928.    define such "LDnnn" to be either "Lnnn-LInnn-2.b", "Lnnn", or any other
  1929.    string, as necessary.  This is accomplished via the ASM_OUTPUT_CASE_END
  1930.    macro.  See m68k/sgs.h for an example; for versions without the bug.
  1931.  
  1932.    They also do not like things like "pea 1.w", so we simple leave off
  1933.    the .w on small constants. 
  1934.  
  1935.    This routine is responsible for distinguishing between -fpic and -fPIC 
  1936.    style relocations in an address.  When generating -fpic code the
  1937.    offset is output in word mode (eg movel a5@(_foo:w), a0).  When generating
  1938.    -fPIC code the offset is output in long mode (eg movel a5@(_foo:l), a0) */
  1939.  
  1940. void
  1941. print_operand_address (file, addr)
  1942.      FILE *file;
  1943.      rtx addr;
  1944. {
  1945.   register rtx reg1, reg2, breg, ireg;
  1946.   rtx offset;
  1947.  
  1948.   switch (GET_CODE (addr))
  1949.     {
  1950.       case REG:
  1951. #ifdef MOTOROLA
  1952.     fprintf (file, "(%s)", reg_names[REGNO (addr)]);
  1953. #else
  1954.     fprintf (file, "%s@", reg_names[REGNO (addr)]);
  1955. #endif
  1956.     break;
  1957.       case PRE_DEC:
  1958. #ifdef MOTOROLA
  1959.     fprintf (file, "-(%s)", reg_names[REGNO (XEXP (addr, 0))]);
  1960. #else
  1961.     fprintf (file, "%s@-", reg_names[REGNO (XEXP (addr, 0))]);
  1962. #endif
  1963.     break;
  1964.       case POST_INC:
  1965. #ifdef MOTOROLA
  1966.     fprintf (file, "(%s)+", reg_names[REGNO (XEXP (addr, 0))]);
  1967. #else
  1968.     fprintf (file, "%s@+", reg_names[REGNO (XEXP (addr, 0))]);
  1969. #endif
  1970.     break;
  1971.       case PLUS:
  1972.     reg1 = reg2 = ireg = breg = offset = 0;
  1973.     if (CONSTANT_ADDRESS_P (XEXP (addr, 0)))
  1974.       {
  1975.         offset = XEXP (addr, 0);
  1976.         addr = XEXP (addr, 1);
  1977.       }
  1978.     else if (CONSTANT_ADDRESS_P (XEXP (addr, 1)))
  1979.       {
  1980.         offset = XEXP (addr, 1);
  1981.         addr = XEXP (addr, 0);
  1982.       }
  1983.     if (GET_CODE (addr) != PLUS)
  1984.       {
  1985.         ;
  1986.       }
  1987.     else if (GET_CODE (XEXP (addr, 0)) == SIGN_EXTEND)
  1988.       {
  1989.         reg1 = XEXP (addr, 0);
  1990.         addr = XEXP (addr, 1);
  1991.       }
  1992.     else if (GET_CODE (XEXP (addr, 1)) == SIGN_EXTEND)
  1993.       {
  1994.         reg1 = XEXP (addr, 1);
  1995.         addr = XEXP (addr, 0);
  1996.       }
  1997.     else if (GET_CODE (XEXP (addr, 0)) == MULT)
  1998.       {
  1999.         reg1 = XEXP (addr, 0);
  2000.         addr = XEXP (addr, 1);
  2001.       }
  2002.     else if (GET_CODE (XEXP (addr, 1)) == MULT)
  2003.       {
  2004.         reg1 = XEXP (addr, 1);
  2005.         addr = XEXP (addr, 0);
  2006.       }
  2007.     else if (GET_CODE (XEXP (addr, 0)) == REG)
  2008.       {
  2009.         reg1 = XEXP (addr, 0);
  2010.         addr = XEXP (addr, 1);
  2011.       }
  2012.     else if (GET_CODE (XEXP (addr, 1)) == REG)
  2013.       {
  2014.         reg1 = XEXP (addr, 1);
  2015.         addr = XEXP (addr, 0);
  2016.       }
  2017.     if (GET_CODE (addr) == REG || GET_CODE (addr) == MULT
  2018.         || GET_CODE (addr) == SIGN_EXTEND)
  2019.       {
  2020.         if (reg1 == 0)
  2021.           {
  2022.         reg1 = addr;
  2023.           }
  2024.         else
  2025.           {
  2026.         reg2 = addr;
  2027.           }
  2028.         addr = 0;
  2029.       }
  2030. #if 0    /* for OLD_INDEXING */
  2031.     else if (GET_CODE (addr) == PLUS)
  2032.       {
  2033.         if (GET_CODE (XEXP (addr, 0)) == REG)
  2034.           {
  2035.         reg2 = XEXP (addr, 0);
  2036.         addr = XEXP (addr, 1);
  2037.           }
  2038.         else if (GET_CODE (XEXP (addr, 1)) == REG)
  2039.           {
  2040.         reg2 = XEXP (addr, 1);
  2041.         addr = XEXP (addr, 0);
  2042.           }
  2043.       }
  2044. #endif
  2045.     if (offset != 0)
  2046.       {
  2047.         if (addr != 0)
  2048.           {
  2049.         abort ();
  2050.           }
  2051.         addr = offset;
  2052.       }
  2053.     if ((reg1 && (GET_CODE (reg1) == SIGN_EXTEND
  2054.               || GET_CODE (reg1) == MULT))
  2055.         || (reg2 != 0 && REGNO_OK_FOR_BASE_P (REGNO (reg2))))
  2056.       {
  2057.         breg = reg2;
  2058.         ireg = reg1;
  2059.       }
  2060.     else if (reg1 != 0 && REGNO_OK_FOR_BASE_P (REGNO (reg1)))
  2061.       {
  2062.         breg = reg1;
  2063.         ireg = reg2;
  2064.       }
  2065.     if (ireg != 0 && breg == 0 && GET_CODE (addr) == LABEL_REF
  2066.         && ! (flag_pic && ireg == pic_offset_table_rtx))
  2067.       {
  2068.         int scale = 1;
  2069.         if (GET_CODE (ireg) == MULT)
  2070.           {
  2071.         scale = INTVAL (XEXP (ireg, 1));
  2072.         ireg = XEXP (ireg, 0);
  2073.           }
  2074.         if (GET_CODE (ireg) == SIGN_EXTEND)
  2075.           {
  2076. #ifdef MOTOROLA
  2077. #ifdef SGS
  2078.         asm_fprintf (file, "%LLD%d(%Rpc,%s.w",
  2079.                  CODE_LABEL_NUMBER (XEXP (addr, 0)),
  2080.                  reg_names[REGNO (XEXP (ireg, 0))]);
  2081. #else
  2082.         asm_fprintf (file, "%LL%d-%LLI%d.b(%Rpc,%s.w",
  2083.                  CODE_LABEL_NUMBER (XEXP (addr, 0)),
  2084.                  CODE_LABEL_NUMBER (XEXP (addr, 0)),
  2085.                  reg_names[REGNO (XEXP (ireg, 0))]);
  2086. #endif
  2087. #else
  2088.         asm_fprintf (file, "%Rpc@(%LL%d-%LLI%d-2:b,%s:w",
  2089.                  CODE_LABEL_NUMBER (XEXP (addr, 0)),
  2090.                  CODE_LABEL_NUMBER (XEXP (addr, 0)),
  2091.                  reg_names[REGNO (XEXP (ireg, 0))]);
  2092. #endif
  2093.           }
  2094.         else
  2095.           {
  2096. #ifdef MOTOROLA
  2097. #ifdef SGS
  2098.         asm_fprintf (file, "%LLD%d(%Rpc,%s.l",
  2099.                  CODE_LABEL_NUMBER (XEXP (addr, 0)),
  2100.                  reg_names[REGNO (ireg)]);
  2101. #else
  2102.         asm_fprintf (file, "%LL%d-%LLI%d.b(%Rpc,%s.l",
  2103.                  CODE_LABEL_NUMBER (XEXP (addr, 0)),
  2104.                  CODE_LABEL_NUMBER (XEXP (addr, 0)),
  2105.                  reg_names[REGNO (ireg)]);
  2106. #endif
  2107. #else
  2108.         asm_fprintf (file, "%Rpc@(%LL%d-%LLI%d-2:b,%s:l",
  2109.                  CODE_LABEL_NUMBER (XEXP (addr, 0)),
  2110.                  CODE_LABEL_NUMBER (XEXP (addr, 0)),
  2111.                  reg_names[REGNO (ireg)]);
  2112. #endif
  2113.           }
  2114.         if (scale != 1)
  2115.           {
  2116. #ifdef MOTOROLA
  2117.         fprintf (file, "*%d", scale);
  2118. #else
  2119.         fprintf (file, ":%d", scale);
  2120. #endif
  2121.           }
  2122.         putc (')', file);
  2123.         break;
  2124.       }
  2125.     if (breg != 0 && ireg == 0 && GET_CODE (addr) == LABEL_REF
  2126.         && ! (flag_pic && breg == pic_offset_table_rtx))
  2127.       {
  2128. #ifdef MOTOROLA
  2129. #ifdef SGS
  2130.         asm_fprintf (file, "%LLD%d(%Rpc,%s.l",
  2131.              CODE_LABEL_NUMBER (XEXP (addr, 0)),
  2132.              reg_names[REGNO (breg)]);
  2133. #else
  2134.         asm_fprintf (file, "%LL%d-%LLI%d.b(%Rpc,%s.l",
  2135.              CODE_LABEL_NUMBER (XEXP (addr, 0)),
  2136.              CODE_LABEL_NUMBER (XEXP (addr, 0)),
  2137.              reg_names[REGNO (breg)]);
  2138. #endif
  2139. #else
  2140.         asm_fprintf (file, "%Rpc@(%LL%d-%LLI%d-2:b,%s:l",
  2141.              CODE_LABEL_NUMBER (XEXP (addr, 0)),
  2142.              CODE_LABEL_NUMBER (XEXP (addr, 0)),
  2143.              reg_names[REGNO (breg)]);
  2144. #endif
  2145.         putc (')', file);
  2146.         break;
  2147.       }
  2148.     if (ireg != 0 || breg != 0)
  2149.       {
  2150.         int scale = 1;
  2151.         if (breg == 0)
  2152.           {
  2153.         abort ();
  2154.           }
  2155.         if (! flag_pic && addr && GET_CODE (addr) == LABEL_REF)
  2156.           {
  2157.         abort ();
  2158.           }
  2159. #ifdef MOTOROLA
  2160.         if (addr != 0)
  2161.           {
  2162.         output_addr_const (file, addr);
  2163.             if (flag_pic && (breg == pic_offset_table_rtx))
  2164.               fprintf (file, "@GOT");
  2165.           }
  2166.         fprintf (file, "(%s", reg_names[REGNO (breg)]);
  2167.         if (ireg != 0)
  2168.           {
  2169.         putc (',', file);
  2170.           }
  2171. #else
  2172.         fprintf (file, "%s@(", reg_names[REGNO (breg)]);
  2173.         if (addr != 0)
  2174.           {
  2175.         output_addr_const (file, addr);
  2176.             if ((flag_pic == 1) && (breg == pic_offset_table_rtx))
  2177.               fprintf (file, ":w");
  2178.             if ((flag_pic == 2) && (breg == pic_offset_table_rtx))
  2179.               fprintf (file, ":l");
  2180.             if ((flag_pic == 3) && (breg == pic_offset_table_rtx))
  2181.               fprintf (file, ":w");
  2182.           }
  2183.         if (addr != 0 && ireg != 0)
  2184.           {
  2185.         putc (',', file);
  2186.           }
  2187. #endif
  2188.         if (ireg != 0 && GET_CODE (ireg) == MULT)
  2189.           {
  2190.         scale = INTVAL (XEXP (ireg, 1));
  2191.         ireg = XEXP (ireg, 0);
  2192.           }
  2193.         if (ireg != 0 && GET_CODE (ireg) == SIGN_EXTEND)
  2194.           {
  2195. #ifdef MOTOROLA
  2196.         fprintf (file, "%s.w", reg_names[REGNO (XEXP (ireg, 0))]);
  2197. #else
  2198.         fprintf (file, "%s:w", reg_names[REGNO (XEXP (ireg, 0))]);
  2199. #endif
  2200.           }
  2201.         else if (ireg != 0)
  2202.           {
  2203. #ifdef MOTOROLA
  2204.         fprintf (file, "%s.l", reg_names[REGNO (ireg)]);
  2205. #else
  2206.         fprintf (file, "%s:l", reg_names[REGNO (ireg)]);
  2207. #endif
  2208.           }
  2209.         if (scale != 1)
  2210.           {
  2211. #ifdef MOTOROLA
  2212.         fprintf (file, "*%d", scale);
  2213. #else
  2214.         fprintf (file, ":%d", scale);
  2215. #endif
  2216.           }
  2217.         putc (')', file);
  2218.         break;
  2219.       }
  2220.     else if (reg1 != 0 && GET_CODE (addr) == LABEL_REF
  2221.          && ! (flag_pic && reg1 == pic_offset_table_rtx))    
  2222.       {
  2223. #ifdef MOTOROLA
  2224. #ifdef SGS
  2225.         asm_fprintf (file, "%LLD%d(%Rpc,%s.l)",
  2226.              CODE_LABEL_NUMBER (XEXP (addr, 0)),
  2227.              reg_names[REGNO (reg1)]);
  2228. #else
  2229.         asm_fprintf (file, "%LL%d-%LLI%d.b(%Rpc,%s.l)",
  2230.              CODE_LABEL_NUMBER (XEXP (addr, 0)),
  2231.              CODE_LABEL_NUMBER (XEXP (addr, 0)),
  2232.              reg_names[REGNO (reg1)]);
  2233. #endif
  2234. #else
  2235.         asm_fprintf (file, "%Rpc@(%LL%d-%LLI%d-2:b,%s:l)",
  2236.              CODE_LABEL_NUMBER (XEXP (addr, 0)),
  2237.              CODE_LABEL_NUMBER (XEXP (addr, 0)),
  2238.              reg_names[REGNO (reg1)]);
  2239. #endif
  2240.         break;
  2241.       }
  2242.     /* FALL-THROUGH (is this really what we want? */
  2243.       default:
  2244.         if (GET_CODE (addr) == CONST_INT
  2245.         && INTVAL (addr) < 0x8000
  2246.         && INTVAL (addr) >= -0x8000)
  2247.       {
  2248. #ifdef MOTOROLA
  2249. #ifdef SGS
  2250.         /* Many SGS assemblers croak on size specifiers for constants. */
  2251.         fprintf (file, "%d", INTVAL (addr));
  2252. #else
  2253.         fprintf (file, "%d.w", INTVAL (addr));
  2254. #endif
  2255. #else
  2256.         fprintf (file, "%d:w", INTVAL (addr));
  2257. #endif
  2258.       }
  2259.     else if (TARGET_PC_REL && GET_CODE (addr) == SYMBOL_REF
  2260.          && SYMBOL_REF_FLAG (addr) && !SYMBOL_REF_USED (addr))
  2261.       {
  2262. #ifdef MOTOROLA
  2263.         output_addr_const (file, addr);
  2264.         fputs ("(pc)", file);
  2265. #else
  2266.         fputs ("pc@(", file);
  2267.         output_addr_const (file, addr);
  2268.         putc (')', file);
  2269. #endif
  2270.       }
  2271.     else
  2272.       {
  2273.         output_addr_const (file, addr);
  2274.       }
  2275.     break;
  2276.     }
  2277. }
  2278.  
  2279. /* Check for cases where a clr insns can be omitted from code using
  2280.    strict_low_part sets.  For example, the second clrl here is not needed:
  2281.    clrl d0; movw a0@+,d0; use d0; clrl d0; movw a0@+; use d0; ...
  2282.  
  2283.    MODE is the mode of this STRICT_LOW_PART set.  FIRST_INSN is the clear
  2284.    insn we are checking for redundancy.  TARGET is the register set by the
  2285.    clear insn.  */
  2286.  
  2287. int
  2288. strict_low_part_peephole_ok (mode, first_insn, target)
  2289.      enum machine_mode mode;
  2290.      rtx first_insn;
  2291.      rtx target;
  2292. {
  2293.   rtx p;
  2294.  
  2295.   p = prev_nonnote_insn (first_insn);
  2296.  
  2297.   while (p)
  2298.     {
  2299.       /* If it isn't an insn, then give up.  */
  2300.       if (GET_CODE (p) != INSN)
  2301.     return 0;
  2302.  
  2303.       if (reg_set_p (target, p))
  2304.     {
  2305.       rtx set = single_set (p);
  2306.       rtx dest;
  2307.  
  2308.       /* If it isn't an easy to recognize insn, then give up.  */
  2309.       if (! set)
  2310.         return 0;
  2311.  
  2312.       dest = SET_DEST (set);
  2313.  
  2314.       /* If this sets the entire target register to zero, then our
  2315.          first_insn is redundant.  */
  2316.       if (rtx_equal_p (dest, target)
  2317.           && SET_SRC (set) == const0_rtx)
  2318.         return 1;
  2319.       else if (GET_CODE (dest) == STRICT_LOW_PART
  2320.            && GET_CODE (XEXP (dest, 0)) == REG
  2321.            && REGNO (XEXP (dest, 0)) == REGNO (target)
  2322.            && (GET_MODE_SIZE (GET_MODE (XEXP (dest, 0)))
  2323.                <= GET_MODE_SIZE (mode)))
  2324.         /* This is a strict low part set which modifies less than
  2325.            we are using, so it is safe.  */
  2326.         ;
  2327.       else
  2328.         return 0;
  2329.     }
  2330.  
  2331.       p = prev_nonnote_insn (p);
  2332.  
  2333.     }
  2334.  
  2335.   return 0;
  2336. }
  2337.  
  2338. #ifdef ENCODE_SECTION_INFO
  2339. /* Does operand (which is a symbolic_operand) live in text space? If
  2340.    so SYMBOL_REF_FLAG, which is set by ENCODE_SECTION_INFO, will be true.*/
  2341.  
  2342. int
  2343. read_only_operand (operand)
  2344.      rtx operand;
  2345. {
  2346.   if (GET_CODE (operand) == CONST)
  2347.     operand = XEXP (XEXP (operand, 0), 0);
  2348.   if (GET_CODE (operand) == SYMBOL_REF)
  2349.     return SYMBOL_REF_FLAG (operand) || CONSTANT_POOL_ADDRESS_P (operand);
  2350.   return 1;
  2351. }
  2352. #endif
  2353.